// 获取年龄，性别，生日
export function getInfoFromIdcard(idcard) {
    var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
    if (!reg.test(idcard)) {
        return;
    }
    let birth = idcard.substring(6, 10) + "-" + idcard.substring(10, 12) + "-" + idcard.substring(12, 14);
    let sex = parseInt(idcard.substr(16, 1)) % 2 == 1 ? '男' : '女';
    let myDate = new Date();
    let month = myDate.getMonth() + 1;
    let day = myDate.getDate();
    let age = myDate.getFullYear() - idcard.substring(6, 10) - 1;
    // 已经过生日了，加一岁
    if (idcard.substring(10, 12) < month || idcard.substring(10, 12) == month && idcard.substring(12, 14) <= day) {
        age++;
    }
    return {
        birth,
        age,
        sex,
    }
}